﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="ProductMag.aspx.cs" Inherits="ProductMag" Trace="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .imgProduct
        {
            float: left;
        }
        .lblName
        {
            font-size: xx-large;
            color: Red;
            font-variant: small-caps;
            font-weight: bolder;
            clear: right;
        }
        .lblPrice
        {
            margin-top: 30px;
            font-size: xx-large;
            color: Red;
            font-variant: small-caps;
            font-weight: bolder;
        }
        .lblDescription
        {
        }
        .ImageContainer
        {
        }
    </style>
    <script type="text/javascript">
        function BlockUI(elementID) {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_beginRequest(function () {
                $("#" + elementID).block({ message: '<table align = "center" class="StatusBar"><tr><td>' +
     '<img src="loadingAnim.gif"/></td></tr></table>',
                    css: {},
                    overlayCSS: { backgroundColor: '#000000', opacity: 0.6, border: '3px solid #63B2EB'
                    }
                });
            });

            prm.add_endRequest(function () {
                $("#" + elementID).unblock();
            });
        }

        $(document).ready(function () {
            BlockUI("dvGrid");
            $.blockUI.defaults.css = {};
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager runat="server" />
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
                <div id="Div1" runat="server" class="ImageContainer">
                    <asp:Image ID="imgProduct" CssClass="imgProduct" alt="" src="Images/Image_not_found.jpg"
                        runat="server" />
                </div>
            </td>
            <td>
                <div id="Div2" style="clear: right;" runat="server">
                    <asp:Label Text="" ID="lblName" CssClass="lblName" runat="server" /><br />
                    <asp:Label Text="" ID="lblDescription" CssClass="lblDescription" runat="server" /><br />
                    <asp:Label Text="" ID="lblPrice" CssClass="lblPrice" runat="server" /><br />
                    <asp:Label ID="Label2" Text="Reduce or set new amount for this product <br/> (Remove amount '0' for complete product deletion):"
                        runat="server" /><br />
                    <div>
                        <div id="dvGrid" style="padding-top: 10px; padding-bottom: 10px; width: 100%">
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:Label ID="Label1" Text="Amount:" runat="server" />
                                    <asp:TextBox runat="server" ID="txtAmountToRemove" Text="0" /><br />
                                    <asp:Button Text="Reduce product amount" CssClass="btnChangeStatus" runat="server" ID="btnRemove"
                                        OnClick="btnRemove_Click" /><br />
                                    <asp:Button Text="Set product amount" CssClass="btnChangeStatus" runat="server" 
                                        ID="btnChange" onclick="btnChange_Click" />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Amount field is required."
                                        ControlToValidate="txtAmountToRemove" runat="server" Display="Dynamic" Style="color: Red;
                                        font-weight: bold;">*</asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="regexAmountValidator" runat="server" ControlToValidate="txtAmountToRemove"
                                        ErrorMessage="Enter a valid number." Style="font-weight: bold; color: Red;" ValidationExpression="^\d+$"
                                        Display="Dynamic">*</asp:RegularExpressionValidator><br />
                                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" Style="color: Red;
                                        font-weight: bold; font-size: large;" />
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="btnRemove" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
</asp:Content>
